#include <iostream>
#include <vector>
using namespace std;

class Solution
{
public:
    int rob(vector<int> &nums)
    {
        if(nums.size() == 1)
            return nums[0];
        vector<int> dpSelect0(nums.size() + 1, 0);
        vector<int> dpUnselect0(nums.size() + 1, 0);
        dpSelect0[1] = nums[0];
        for (int i = 2; i < nums.size(); i++)
        {
            // select0
            dpSelect0[i] = std::max(dpSelect0[i - 2] + nums[i - 1], dpSelect0[i - 1]);
            dpUnselect0[i] = std::max(dpUnselect0[i - 2] + nums[i - 1], dpUnselect0[i - 1]);
        }
        dpSelect0[nums.size()] = dpSelect0[nums.size() - 1];
        dpUnselect0[nums.size()] = std::max(dpUnselect0[nums.size() - 2] + nums[nums.size() - 1], dpUnselect0[nums.size() - 1]);
        return std::max(dpSelect0[nums.size()], dpUnselect0[nums.size()]);
    }
};

int main()
{
    cout << "Code213" << endl;
    Solution s;
    cout << s.rob(vector<int>{1,2}) << endl;
    return 0;
}